//
//  ILGApplePay.h
//  ILGDemo
//
//  Created by HappyWork on 2019/2/14.
//  Copyright © 2019 Happy. All rights reserved.
//

#import <Foundation/Foundation.h>


NS_ASSUME_NONNULL_BEGIN

@protocol ILGApplePayDelegate <NSObject>

/**
 扣款成功的回调

 @param result 如果成功则为{@"orderId":orderId, @"receipt":receipt,@"transactionIdentifier":transactionIdentifier}，否则为{@"orderId":orderId, @"receipt":@"",@"transactionIdentifier":@""}
 @param error 失败
 */
- (void)applePayComplete:(NSDictionary *)result error:(NSError * _Nullable )error;
@end

@interface ILGApplePay : NSObject
@property (nonatomic, weak) id<ILGApplePayDelegate> delegate;

- (void)addTransactionObserver;

/**
 配置商品ID数组, 默认为bundleId+".diamond1~6"
 
 @param array 商品ID数组
 */
- (void)configureProductIdentifierArr:(NSArray *)array;

- (void)pay:(NSString *)productId orderId:(NSString *)orderId;

- (void)finishTransaction:(NSString *)orderId;

@end

NS_ASSUME_NONNULL_END

/* To do ...
 1.保存支付流程log
 
 */

/* 必须要求
 1.确保不串单、不丢单
 
 */

/* 已解决问题
 1.一次支付，两次回调问题：一次失败，有applicationUsername; 一次成功，没有applicationUsername
 
 */
